<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Node.js学习(十七.Mysql数据库常用命令(下)) | 小何blog (记录美好)</title><meta name="keywords" content="系列🏬,Node.js,数据库"><meta name="author" content="六根清静"><meta name="copyright" content="六根清静"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="学习JavaScript之前要先搞清楚计算机基础，分清与HTML等标记语言的区别，这样能更好的帮我们学习JavaScript">
<meta property="og:type" content="article">
<meta property="og:title" content="Node.js学习(十七.Mysql数据库常用命令(下))">
<meta property="og:url" content="https://liugenqingjing2.coding.me/2021/02/23/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B8%83-Mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-%E4%B8%8B/index.html">
<meta property="og:site_name" content="小何blog (记录美好)">
<meta property="og:description" content="学习JavaScript之前要先搞清楚计算机基础，分清与HTML等标记语言的区别，这样能更好的帮我们学习JavaScript">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210223/So5M32ObqLxz.jpg">
<meta property="article:published_time" content="2021-02-23T13:36:23.000Z">
<meta property="article:modified_time" content="2021-02-24T08:11:35.164Z">
<meta property="article:author" content="六根清静">
<meta property="article:tag" content="系列🏬">
<meta property="article:tag" content="Node.js">
<meta property="article:tag" content="数据库">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210223/So5M32ObqLxz.jpg"><link rel="shortcut icon" href="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20200907/wOu*ZmuVb5A4.png"><link rel="canonical" href="https://liugenqingjing2.coding.me/2021/02/23/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B8%83-Mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-%E4%B8%8B/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin="crossorigin"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?e829919a4d931d733ee74d5d97a51582";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap"><script>var GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":20,"languages":{"author":"作者: 六根清静","link":"链接: ","source":"来源: 小何blog (记录美好)","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#121212","position":"bottom-left"},
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: true
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-02-24 16:11:35'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
   if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }
  const autoChangeMode = '2'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified
    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }const asideStatus = saveToLocal.get('aside-status')
if (asideStatus !== undefined) {
   if (asideStatus === 'hide') {
     document.documentElement.classList.add('hide-aside')
   } else {
     document.documentElement.classList.remove('hide-aside')
   }
}})()</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/HCLonely/images@master/others/heartbeat.min.css"><link rel="stylesheet" href="/css/shuo.css"/><link rel="stylesheet" href="/magnetcss/magnet.css"/><link rel="stylesheet" href="/css/calendar.css"/><link rel="stylesheet" href="//at.alicdn.com/t/font_2060620_l0j6b710zk.css"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/font-awesome-animation.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/macblack.css"><link rel="stylesheet" href="/css/change.css"><link rel="stylesheet" href="/news/css/news.css"/><style type="text/css">#toggle-sidebar {bottom: 80px}</style><link rel="stylesheet" href="/magnet/css/catalogMagnet.css"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.css"/><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/iconfont.min.css"><link rel="stykesheet" href="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/css/pool.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css"/><link rel="stylesheet" href="/zan/zan.css"><link rel="stylesheet" href="/swiper/swiper.min.css"><link rel="stylesheet" href="/swiper/swiperstyle.css"><style>#article-container.post-content h1:before, h2:before, h3:before, h4:before, h5:before, h6:before { -webkit-animation: avatar_turn_around 1s linear infinite; -moz-animation: avatar_turn_around 1s linear infinite; -o-animation: avatar_turn_around 1s linear infinite; -ms-animation: avatar_turn_around 1s linear infinite; animation: avatar_turn_around 1s linear infinite; }</style><meta name="generator" content="Hexo 5.0.0"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="wizard-scene"><div class="wizard-objects"><div class="wizard-square"></div><div class="wizard-circle"></div><div class="wizard-triangle"></div></div><div class="wizard"><div class="wizard-body"></div><div class="wizard-right-arm"><div class="wizard-right-hand"></div></div><div class="wizard-left-arm"><div class="wizard-left-hand"></div></div><div class="wizard-head"><div class="wizard-beard"></div><div class="wizard-face"><div class="wizard-adds"></div></div><div class="wizard-hat"><div class="wizard-hat-of-the-hat"></div><div class="wizard-four-point-star --first"></div><div class="wizard-four-point-star --second"></div><div class="wizard-four-point-star --third"></div></div></div></div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" data-lazy-src="http://01.027cgb.com/632500/1576904533264.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">138</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">63</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/stars/"><i class="fa-fw fas fa-star faa-shake animated-hover"></i><span> 收藏网址</span></a></div><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-zhuye faa-shake animated-hover"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog.html"><i class="fa-fw iconfont icon-Artboard faa-shake animated-hover"></i><span> 博客</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-guidang faa-shake animated-hover"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian faa-shake animated-hover"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw iconfont icon-yule1"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/movies/"><i class="fa-fw iconfont icon-yingshi faa-shake animated-hover"></i><span> 影视</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw iconfont icon-youxi1 faa-shake animated-hover"></i><span> 游戏</span></a></li><li><a class="site-page" href="/galleryGroup"><i class="fa-fw iconfont icon-tuku faa-shake animated-hover"></i><span> 图库</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/messagepad/"><i class="fa-fw iconfont icon-ziyuan6 faa-shake animated-hover"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw iconfont icon-icon_xinyong_xianxing_jijin- faa-shake animated-hover"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw iconfont icon-guanyuwomen faa-shake animated-hover"></i><span> 关于我</span></a></div></div></div></div><div id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210223/So5M32ObqLxz.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">小何blog (记录美好)</a></span><span id="menus"><div id="search_button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/stars/"><i class="fa-fw fas fa-star faa-shake animated-hover"></i><span> 收藏网址</span></a></div><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw iconfont icon-zhuye faa-shake animated-hover"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog.html"><i class="fa-fw iconfont icon-Artboard faa-shake animated-hover"></i><span> 博客</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw iconfont icon-guidang faa-shake animated-hover"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw iconfont icon-biaoqian faa-shake animated-hover"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw iconfont icon-yule1"></i><span> 娱乐</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/movies/"><i class="fa-fw iconfont icon-yingshi faa-shake animated-hover"></i><span> 影视</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw iconfont icon-youxi1 faa-shake animated-hover"></i><span> 游戏</span></a></li><li><a class="site-page" href="/galleryGroup"><i class="fa-fw iconfont icon-tuku faa-shake animated-hover"></i><span> 图库</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/messagepad/"><i class="fa-fw iconfont icon-ziyuan6 faa-shake animated-hover"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw iconfont icon-icon_xinyong_xianxing_jijin- faa-shake animated-hover"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw iconfont icon-guanyuwomen faa-shake animated-hover"></i><span> 关于我</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><h1 class="post-title">Node.js学习(十七.Mysql数据库常用命令(下))</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-02-23T13:36:23.000Z" title="发表于 2021-02-23 21:36:23">2021-02-23</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-02-24T08:11:35.164Z" title="更新于 2021-02-24 16:11:35">2021-02-24</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%89%8D%E7%AB%AF%E5%AD%A6%E4%B9%A0/">前端学习</a></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">2.1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>9分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="Node-js学习-十七-Mysql数据库常用命令-下-："><a href="#Node-js学习-十七-Mysql数据库常用命令-下-：" class="headerlink" title="Node.js学习(十七.Mysql数据库常用命令(下))："></a>Node.js学习(十七.Mysql数据库常用命令(下))：</h1><ul>
<li><h2 id="准备测试数据："><a href="#准备测试数据：" class="headerlink" title="准备测试数据："></a>准备测试数据：</h2><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">-- 创建数据库</span><br><span class="line">create database qianduan_test charset&#x3D;utf8;</span><br><span class="line"></span><br><span class="line">-- 使用数据库</span><br><span class="line">use qianduan_test;</span><br><span class="line"></span><br><span class="line">-- students表</span><br><span class="line">create table students(</span><br><span class="line">    id int unsigned primary key auto_increment not null,</span><br><span class="line">    name varchar(20) default &#39;&#39;,</span><br><span class="line">    age tinyint unsigned default 0,</span><br><span class="line">    height decimal(5,2),</span><br><span class="line">    gender enum(&#39;男&#39;,&#39;女&#39;,&#39;中性&#39;,&#39;保密&#39;) default &#39;保密&#39;,</span><br><span class="line">    cls_id int unsigned default 0,</span><br><span class="line">    is_delete bit default 0</span><br><span class="line">);</span><br><span class="line"></span><br><span class="line">-- classes表</span><br><span class="line">create table classes (</span><br><span class="line">    id int unsigned auto_increment primary key not null,</span><br><span class="line">    name varchar(30) not null</span><br><span class="line">);</span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">-- 向students表中插入数据</span><br><span class="line">insert into students values</span><br><span class="line">(0,&#39;小明&#39;,18,180.00,2,1,0),</span><br><span class="line">(0,&#39;小月月&#39;,18,180.00,2,2,1),</span><br><span class="line">(0,&#39;彭于晏&#39;,29,185.00,1,1,0),</span><br><span class="line">(0,&#39;刘德华&#39;,59,175.00,1,2,1),</span><br><span class="line">(0,&#39;黄蓉&#39;,38,160.00,2,1,0),</span><br><span class="line">(0,&#39;凤姐&#39;,28,150.00,4,2,1),</span><br><span class="line">(0,&#39;王祖贤&#39;,18,172.00,2,1,1),</span><br><span class="line">(0,&#39;周杰伦&#39;,36,NULL,1,1,0),</span><br><span class="line">(0,&#39;程坤&#39;,27,181.00,1,2,0),</span><br><span class="line">(0,&#39;刘亦菲&#39;,25,166.00,2,2,0),</span><br><span class="line">(0,&#39;金星&#39;,33,162.00,3,3,1),</span><br><span class="line">(0,&#39;静香&#39;,12,180.00,2,4,0),</span><br><span class="line">(0,&#39;郭靖&#39;,12,170.00,1,4,0),</span><br><span class="line">(0,&#39;周杰&#39;,34,176.00,2,5,0);</span><br><span class="line"></span><br><span class="line">-- 向classes表中插入数据</span><br><span class="line">insert into classes values (0, &quot;qianduan_01期&quot;), (0, &quot;qianduan_02期&quot;);</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><h2 id="查询练习"><a href="#查询练习" class="headerlink" title="查询练习:"></a>查询练习:</h2><ul>
<li><h4 id="查询所有字段"><a href="#查询所有字段" class="headerlink" title="查询所有字段:"></a>查询所有字段:</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from 表名;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><h4 id="查询指定字段"><a href="#查询指定字段" class="headerlink" title="查询指定字段:"></a>查询指定字段:</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select 列1,列2,... from 表名;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><h4 id="使用-as-给字段起别名"><a href="#使用-as-给字段起别名" class="headerlink" title="使用 as 给字段起别名:"></a>使用 as 给字段起别名:</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select 字段 as 名字.... from 表名;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><h4 id="可以通过-as-给表起别名"><a href="#可以通过-as-给表起别名" class="headerlink" title="可以通过 as 给表起别名:"></a>可以通过 as 给表起别名:</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select 别名.字段 .... from 表名 as 别名;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><h4 id="消除重复行-查性别"><a href="#消除重复行-查性别" class="headerlink" title="消除重复行(查性别):"></a>消除重复行(查性别):</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">distinct 字段 </span><br></pre></td></tr></table></figure>

<ul>
<li><p><strong>使用<code>distinct</code>关键字的做法清除重复的记录：</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select distinct gender from students;</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>使用分组的做法清除重复的记录:</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender from students group by gender;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="条件查询"><a href="#条件查询" class="headerlink" title="条件查询:"></a>条件查询:</h4><figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select .... from 表名 where .....</span><br></pre></td></tr></table></figure>

<ul>
<li><p><strong>比较运算符:</strong></p>
<ul>
<li><p><code>&lt; &gt; = !=</code></p>
</li>
<li><p>查询年纪大于18岁的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &gt; 18;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>查询年纪小于18岁的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &lt; 18;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>查询小于或者等于18岁的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &lt;&#x3D; 18;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>查询年龄为18岁的所有学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &#x3D; 18;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>查询年龄不为18岁的所有学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">    select * from students where age !&#x3D; 18;</span><br><span class="line">    或</span><br><span class="line">select * from students where age &lt;&gt; 18;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><p><strong>逻辑运算符：</strong></p>
<ul>
<li><p><code>and  /  between .. and ...</code></p>
</li>
<li><p>18和28之间的所有学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &gt; 18 and age &lt; 28;  --不包含18 和28</span><br><span class="line"></span><br><span class="line">select * from students where age &gt;&#x3D; 18 and age &lt;&#x3D; 28;  --包含18 和28</span><br><span class="line">或</span><br><span class="line">select * from students where age between 18 and 28;  --包含18 和28</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>18岁以上的女性的学生信息：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &gt; 18 and gender&#x3D;&quot;女&quot;;</span><br><span class="line">select * from students where age &gt; 18 and gender&#x3D;2;   </span><br><span class="line">--枚举的数据类型可以用数字来表示，数字从1开始</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>or</code></p>
</li>
<li><p>18以上或者身高高过180(包含)以上的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &gt; 18 or height &gt;&#x3D; 180.00;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>not</code></p>
</li>
<li><p>不在 18岁以上的女性 这个范围内的信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where not (age&gt;18 and gender&#x3D;2);</span><br></pre></td></tr></table></figure>

</li>
</ul>
</li>
</ul>
<hr>
</li>
<li><h4 id="模糊查询-where-name-like-要查询的数据"><a href="#模糊查询-where-name-like-要查询的数据" class="headerlink" title="模糊查询(where name like 要查询的数据):"></a>模糊查询(where name like 要查询的数据):</h4><ul>
<li><p><code>like </code>:</p>
</li>
<li><p><code>%</code> 替换任意个</p>
</li>
<li><p><code>_</code> 替换1个</p>
</li>
<li><p>查询姓名中 以 “小” 开始的名字的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where name like &quot;小%&quot;;</span><br></pre></td></tr></table></figure>
<hr>
</li>
</ul>
</li>
<li><p>查询姓名中 有 “小” 所有的名字的学生信息:</p>
  <figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where name like &quot;%小%&quot;;</span><br></pre></td></tr></table></figure>

<hr>
<ul>
<li><p>查询至少有2个字的名字的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where name like &quot;__%&quot;;</span><br></pre></td></tr></table></figure>

<hr>
</li>
</ul>
<hr>
</li>
<li><h4 id="范围查询"><a href="#范围查询" class="headerlink" title="范围查询:"></a>范围查询:</h4><ul>
<li><p><code>in (1, 3, 8)</code>表示在一个非连续的范围内。</p>
</li>
<li><p>查询 年龄为18或34的姓名的学生信息：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age &#x3D; 18 or age &#x3D; 34;</span><br><span class="line">select * from students where age in (18, 34);  -- (18, 34)不是区间，是确切的值</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>not in</code> 不非连续的范围之内。</p>
</li>
<li><p>年龄不是 18或34岁的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age not in (18, 34);</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>between ... and ...</code>表示在一个连续的范围内。</p>
</li>
<li><p>查询年龄在18到34之间的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age between 18 and 34;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>not between ... and ...</code>表示不在一个连续的范围内。</p>
</li>
<li><p>查询年龄不在18到34之间的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where age not between 18 and 34;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="空判断"><a href="#空判断" class="headerlink" title="空判断:"></a>空判断:</h4><ul>
<li><p>判空 <code>is null</code>:</p>
</li>
<li><p>查询身高为空的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where height is null;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>判非空<code>is not null</code>。</p>
</li>
<li><p>查询身高不为空的学生信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where height is not null;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="排序"><a href="#排序" class="headerlink" title="排序:"></a>排序:</h4><ul>
<li><p><code>order by</code> 字段</p>
</li>
<li><p><code>asc</code>从小到大排列，即升序</p>
</li>
<li><p><code>desc</code>从大到小排序，即降序</p>
</li>
<li><p>查询年龄在18到34岁之间的男性，按照年龄从小到大到排序:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where gender&#x3D;1 and age between 18 and 34 order by age asc;</span><br></pre></td></tr></table></figure>
</li>
<li><p>查询年龄在18到34岁之间的女性，身高从高到矮排序:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where gender&#x3D;2 and age between 18 and 34 order by height desc;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>order by</code> 多个字段。</p>
</li>
<li><p>查询年龄在18到34岁之间的女性，身高从高到矮排序, 如果身高相同的情况下按照年龄从小到大排序：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where gender&#x3D;2 and age between 18 and 34 order by height desc, age asc;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>如果年龄也相同那么按照id从大到小排序:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where gender&#x3D;2 and age between 18 and 34 order by height desc, age asc, id desc;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="聚合函数"><a href="#聚合函数" class="headerlink" title="聚合函数:"></a>聚合函数:</h4><ul>
<li><p>计算总数: <code>count</code>。</p>
</li>
<li><p>查询男性有多少人。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select count(*) from students where gender &#x3D; 1;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>最大值: <code>max</code>。</p>
</li>
<li><p>查询最大的年龄。</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select max(age) from students;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>最小值: <code>min</code></p>
</li>
<li><p>查询女性的最低身高:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select min(height) from students where gender &#x3D; 2; </span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>求和: <code>sum</code>。</p>
</li>
<li><p>计算所有人的年龄总和：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select sum(age) from students;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>平均值: <code>avg</code>。</p>
</li>
<li><p>计算平均年龄：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select avg(age) from students;</span><br></pre></td></tr></table></figure>
</li>
<li><p>计算平均年龄 sum(age)/count(*):</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select sum(age)&#x2F;count(*) from students;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>四舍五入 round(123.23 , 1) 保留1位小数。</p>
</li>
<li><p>计算所有人的平均年龄，保留2位小数：</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select round(avg(age), 2) from students;</span><br></pre></td></tr></table></figure>
</li>
<li><p>聚合函数计算的时候不会把null计算进去</p>
</li>
</ul>
<hr>
</li>
<li><h4 id="分组"><a href="#分组" class="headerlink" title="分组:"></a>分组:</h4><ul>
<li><p><strong>分组的口诀:</strong></p>
</li>
<li><p>每种、每类是分组的关键字眼， 以什么为分组，最好在展示的时候，把这个字段放在第一列</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select 分组的字段  from 表名 group by 分组字段;</span><br></pre></td></tr></table></figure>
</li>
<li><p>按照性别分组,查询所有的性别:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender from students group by gender;</span><br></pre></td></tr></table></figure>
</li>
<li><p>计算每种性别中的人数:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender, count(*) from students group by gender;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>group_concat(...)</code>:</p>
</li>
<li><p>查询同种性别中的姓名<code>group_concat(name)</code>:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender, group_concat(name) from students group by gender;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p>查询每组性别的平均年龄:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender, avg(age) from students group by gender;</span><br></pre></td></tr></table></figure>

<hr>
</li>
<li><p><code>having</code>(注意having和group by 连用 having后通常也要跟 聚合函数)</p>
</li>
<li><p><strong>注意：</strong> 聚合函数如果做为条件出现，<strong>只能和having配合。不能和where配合使用。</strong></p>
</li>
<li><p>查询平均年龄超过30岁的性别，以及姓名:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select gender, avg(age), group_concat(name) from students group by gender having avg(age) &gt; 30;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="分页"><a href="#分页" class="headerlink" title="分页:"></a>分页:</h4><ul>
<li><p><code>limit start, count</code></p>
</li>
<li><p><code>limit</code> 放在最后面(注意)</p>
</li>
<li><p><strong>公式：</strong>``limit (要显示第几页-1) * 每页分多少个, 每页分多少个;`</p>
</li>
<li><p>限制查询出来的数据个数</p>
</li>
<li><p>查询前5个数据:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students limit 5;</span><br></pre></td></tr></table></figure>
</li>
<li><p>每页分2个，要显示第1页  (查询前2个数据) :</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students limit 2;</span><br></pre></td></tr></table></figure>
</li>
<li><p><strong>通用写法：</strong></p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students limit 0, 2;</span><br></pre></td></tr></table></figure>
</li>
<li><p>每页分2个，要显示第2页:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students limit 2, 2;</span><br></pre></td></tr></table></figure>
</li>
<li><p>每页分2个，要显示第4页:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students limit 6, 2;</span><br></pre></td></tr></table></figure>
</li>
<li><p>每页分2个，显示第6页的信息, 按照年龄从小到大排序</p>
</li>
<li><p>先整体排序，再进行分页！</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students order by age asc limit 10, 2;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="连接查询-表与表之间的链接，-为了更好的查出有效数据"><a href="#连接查询-表与表之间的链接，-为了更好的查出有效数据" class="headerlink" title="连接查询   (表与表之间的链接， 为了更好的查出有效数据):"></a>连接查询   (表与表之间的链接， 为了更好的查出有效数据):</h4><ul>
<li><p><code>inner join ... on</code></p>
</li>
<li><p><code>select ... from 表A inner join 表B;</code></p>
</li>
<li><p>查询有能够对应班级的学生以及班级信息:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from studetns inner join classes on students.cls_id&#x3D;classes.id;</span><br></pre></td></tr></table></figure>
</li>
<li><p>查询有能够对应班级的学生以及班级信息，显示学生的所有信息 students.*，只显示班级名称 classes.name:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select s.*, c.name from students as s inner join classes as c on s.cls_id &#x3D; c.id;</span><br></pre></td></tr></table></figure>
</li>
<li><p>查询有能够对应班级的学生以及班级信息, 按照班级名进行排序:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select c.name,s.* from students as s inner join classes as c on s.cls_id &#x3D; c.id order by c.name;</span><br></pre></td></tr></table></figure>

</li>
</ul>
<hr>
</li>
<li><h4 id="子查询-一个查询的结果作为另一个查询的一部分，-会把前者的查询称为子查询"><a href="#子查询-一个查询的结果作为另一个查询的一部分，-会把前者的查询称为子查询" class="headerlink" title="子查询  (一个查询的结果作为另一个查询的一部分， 会把前者的查询称为子查询):"></a>子查询  (一个查询的结果作为另一个查询的一部分， 会把前者的查询称为子查询):</h4><ul>
<li><p><strong>标量子查询:</strong> 子查询返回的结果是一个数据(一行一列)</p>
</li>
<li><p><strong>列子查询:</strong> 返回的结果是一列(一列多行)</p>
</li>
<li><p><strong>行子查询:</strong> 返回的结果是一行(一行多列)</p>
</li>
<li><p>查询出高于平均身高的信息(height):</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select * from students where height &gt; (select avg(height) from students);</span><br></pre></td></tr></table></figure>
</li>
<li><p>查询学生的班级号能够对应的 学生名字:</p>
<figure class="highlight plain"><table><tr><td class="code"><pre><span class="line">select students.name from students where cls_id in (select id from classes);</span><br></pre></td></tr></table></figure>


</li>
</ul>
</li>
</ul>
</li>
</ul>
<hr>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">六根清静</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://liugenqingjing2.coding.me/2021/02/23/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B8%83-Mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-%E4%B8%8B/">https://liugenqingjing2.coding.me/2021/02/23/Node-js学习-十七-Mysql数据库常用命令-下/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://liugenqingjing2.coding.me" target="_blank">小何blog (记录美好)</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E7%B3%BB%E5%88%97%F0%9F%8F%AC/">系列🏬</a><a class="post-meta__tags" href="/tags/Node-js/">Node.js</a><a class="post-meta__tags" href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/">数据库</a></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210223/So5M32ObqLxz.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏<div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="http://qew58kkb2.hn-bkt.clouddn.com/wechat%20%20%281%29.png" target="_blank"><img class="post-qr-code-img" data-lazy-src="http://qew58kkb2.hn-bkt.clouddn.com/wechat%20%20%281%29.png" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li></ul></div></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/02/26/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E5%85%AB-%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93%E4%B9%8BORM%E6%A8%A1%E5%9D%97/"><img class="prev-cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210226/Gi3*M2bO!s2d.jpg" onerror="onerror=null;src='/img/404.jpg'"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Node.js学习(十八.操作数据库之ORM模块)</div></div></a></div><div class="next-post pull-right"><a href="/2021/02/22/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E5%85%AD-%E6%95%B0%E6%8D%AE%E5%BA%93%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C(%E4%B8%8A)/"><img class="next-cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210222/pEId68h9Eq5!.jpg" onerror="onerror=null;src='/img/404.jpg'"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Node.js学习(十六.Mysql数据库常用命令(上))</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2021/03/14/Node-js学习-二十-Node-js项目流程(上)/" title="Node.js学习(二十.Node.js项目流程(上))"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/UMp@B^akHmf8.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-14</div><div class="title">Node.js学习(二十.Node.js项目流程(上))</div></div></a></div><div><a href="/2021/03/21/Node-js学习-二十三-跨域介绍和JSONP介绍/" title="Node.js学习(二十三.跨域介绍和JSONP介绍)"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210321/qWPEashJOuNK.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-21</div><div class="title">Node.js学习(二十三.跨域介绍和JSONP介绍)</div></div></a></div><div><a href="/2021/03/15/Node-js学习-二十一-Node-js项目流程-中/" title="Node.js学习(二十一.Node.js项目流程(中))"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/gSrAfCznw@^F.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-15</div><div class="title">Node.js学习(二十一.Node.js项目流程(中))</div></div></a></div><div><a href="/2021/03/20/Node-js学习-二十二-Node-js项目流程-下/" title="Node.js学习(二十二.Node.js项目流程(下))"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/CvAoe6kC5*f2.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-03-20</div><div class="title">Node.js学习(二十二.Node.js项目流程(下))</div></div></a></div><div><a href="/2021/02/27/Node-js学习-十九-封装操作数据库和CSRF/" title="Node.js学习(十九.封装操作数据库和CSRF)"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210227/EcgLTE4WPOp^.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-27</div><div class="title">Node.js学习(十九.封装操作数据库和CSRF)</div></div></a></div><div><a href="/2021/02/20/Node-js学习-十五-数据库概述/" title="Node.js学习(十五.数据库概述)"><img class="cover" data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210220/lHkEVJKKG1lg.jpg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-02-20</div><div class="title">Node.js学习(十五.数据库概述)</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside_content" id="aside_content"><div class="card-widget card-info"><div class="card-content"><div class="card-info-avatar is-center"><img class="avatar-img" data-lazy-src="http://01.027cgb.com/632500/1576904533264.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">六根清静</div><div class="author-info__description">记录美好，记录生活，记录学习</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">138</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">63</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">8</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/he_chaoming/dashboard/projects?scope=public&amp;&amp;sort="><i class="fab fa-gofore"></i><span>My Gitee</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/he1213114428" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:484695754@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="tencent://message/?uin=484695754" target="_blank" title="QQ"><i class="fab fa-qq"></i></a></div></div></div><div class="card-widget card-recent-post"><div id="gamenews"><div class="card-content"><div class="item-headline"><i class="fas fa-cube"></i><span>ROLL资讯</span><i class="fas fa-retweet" @click="changetype(current)" style="float:right;margin-top:8px"></i></div><div class="newsbar"><span v-for="(type, index) in listtype" v-on:click="addClass(index)" v-bind:class="{ listtypeon:index==current}">{{type}}</span></div><div class="aside-list"><div class="aside-list-item" v-for="(news,index) in newsvue"><a class="thumbnail" href="javascript:void(0)" @click="getnewsdata(index)" :title="news.title"><img class="loaded" onerror="this.onerror=null;this.src='/img/404.jpg'" data-ll-status="loaded" :src="news.imgList[0]"/></a><div class="content"><a class="title" href="javascript:void(0)" @click="getnewsdata(index)" :title="news.title">{{news.title}}</a><time>{{news.postTime}}</time></div></div></div></div><div id="newsmodal"><button class="modalclose" @click="hidemodle()">关闭</button><h2>{{newpostvue.title}} </h2><h4>{{newpostvue.ptime}} &nbsp;&nbsp; {{newpostvue.source}}</h4><div v-html="newpostvue.content"></div></div></div></div><div class="card-widget card-shuo"><div class="card-content" style="height:auto;min-height:280px;"><div class="item-headline"><i class="fas fa-comments"></i><span>&#x8BF4;&#x8BF4</span><a id="shuovisualchange" style="cursor:pointer;float:right" onclick="shuovisualchange()">编辑</a></div><div id="artitalk_main" style="width:100%;height:100%;padding:10px"></div></div></div><div class="sticky_layout"></div><div class="card-widget card-history"><div class="card-content"><div class="item-headline"><i class="fas fa-paw fa-spin"></i><span>那年今日</span></div><div id="history-news" style="height: 100px;overflow: hidden;"><div id="history-card"></div></div></div></div><div class="card-widget card-announcement"><div class="card-content"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">大学生一枚，软件工程，想做全栈攻城狮，哈哈，有兴趣可以加 QQ:484695754 (也可以点上面的logo)，一起交流学习</div></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="card-content"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B8%83-Mysql%E6%95%B0%E6%8D%AE%E5%BA%93%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4-%E4%B8%8B-%EF%BC%9A"><span class="toc-number">1.</span> <span class="toc-text">Node.js学习(十七.Mysql数据库常用命令(下))：</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%87%86%E5%A4%87%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%EF%BC%9A"><span class="toc-number">1.1.</span> <span class="toc-text">准备测试数据：</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2%E7%BB%83%E4%B9%A0"><span class="toc-number">1.2.</span> <span class="toc-text">查询练习:</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2%E6%89%80%E6%9C%89%E5%AD%97%E6%AE%B5"><span class="toc-number">1.2.0.1.</span> <span class="toc-text">查询所有字段:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E8%AF%A2%E6%8C%87%E5%AE%9A%E5%AD%97%E6%AE%B5"><span class="toc-number">1.2.0.2.</span> <span class="toc-text">查询指定字段:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8-as-%E7%BB%99%E5%AD%97%E6%AE%B5%E8%B5%B7%E5%88%AB%E5%90%8D"><span class="toc-number">1.2.0.3.</span> <span class="toc-text">使用 as 给字段起别名:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8F%AF%E4%BB%A5%E9%80%9A%E8%BF%87-as-%E7%BB%99%E8%A1%A8%E8%B5%B7%E5%88%AB%E5%90%8D"><span class="toc-number">1.2.0.4.</span> <span class="toc-text">可以通过 as 给表起别名:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%B6%88%E9%99%A4%E9%87%8D%E5%A4%8D%E8%A1%8C-%E6%9F%A5%E6%80%A7%E5%88%AB"><span class="toc-number">1.2.0.5.</span> <span class="toc-text">消除重复行(查性别):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9D%A1%E4%BB%B6%E6%9F%A5%E8%AF%A2"><span class="toc-number">1.2.0.6.</span> <span class="toc-text">条件查询:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%A8%A1%E7%B3%8A%E6%9F%A5%E8%AF%A2-where-name-like-%E8%A6%81%E6%9F%A5%E8%AF%A2%E7%9A%84%E6%95%B0%E6%8D%AE"><span class="toc-number">1.2.0.7.</span> <span class="toc-text">模糊查询(where name like 要查询的数据):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2"><span class="toc-number">1.2.0.8.</span> <span class="toc-text">范围查询:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E7%A9%BA%E5%88%A4%E6%96%AD"><span class="toc-number">1.2.0.9.</span> <span class="toc-text">空判断:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8E%92%E5%BA%8F"><span class="toc-number">1.2.0.10.</span> <span class="toc-text">排序:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%81%9A%E5%90%88%E5%87%BD%E6%95%B0"><span class="toc-number">1.2.0.11.</span> <span class="toc-text">聚合函数:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%86%E7%BB%84"><span class="toc-number">1.2.0.12.</span> <span class="toc-text">分组:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%88%86%E9%A1%B5"><span class="toc-number">1.2.0.13.</span> <span class="toc-text">分页:</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E8%BF%9E%E6%8E%A5%E6%9F%A5%E8%AF%A2-%E8%A1%A8%E4%B8%8E%E8%A1%A8%E4%B9%8B%E9%97%B4%E7%9A%84%E9%93%BE%E6%8E%A5%EF%BC%8C-%E4%B8%BA%E4%BA%86%E6%9B%B4%E5%A5%BD%E7%9A%84%E6%9F%A5%E5%87%BA%E6%9C%89%E6%95%88%E6%95%B0%E6%8D%AE"><span class="toc-number">1.2.0.14.</span> <span class="toc-text">连接查询   (表与表之间的链接， 为了更好的查出有效数据):</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%AD%90%E6%9F%A5%E8%AF%A2-%E4%B8%80%E4%B8%AA%E6%9F%A5%E8%AF%A2%E7%9A%84%E7%BB%93%E6%9E%9C%E4%BD%9C%E4%B8%BA%E5%8F%A6%E4%B8%80%E4%B8%AA%E6%9F%A5%E8%AF%A2%E7%9A%84%E4%B8%80%E9%83%A8%E5%88%86%EF%BC%8C-%E4%BC%9A%E6%8A%8A%E5%89%8D%E8%80%85%E7%9A%84%E6%9F%A5%E8%AF%A2%E7%A7%B0%E4%B8%BA%E5%AD%90%E6%9F%A5%E8%AF%A2"><span class="toc-number">1.2.0.15.</span> <span class="toc-text">子查询  (一个查询的结果作为另一个查询的一部分， 会把前者的查询称为子查询):</span></a></li></ol></li></ol></li></ol></li></ol></div></div></div><div class="card-widget card-recent-post"><div class="card-content"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/03/21/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%B8%89-%E8%B7%A8%E5%9F%9F%E4%BB%8B%E7%BB%8D%E5%92%8CJSONP%E4%BB%8B%E7%BB%8D/" title="Node.js学习(二十三.跨域介绍和JSONP介绍)"><img data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210321/qWPEashJOuNK.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Node.js学习(二十三.跨域介绍和JSONP介绍)"/></a><div class="content"><a class="title" href="/2021/03/21/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%B8%89-%E8%B7%A8%E5%9F%9F%E4%BB%8B%E7%BB%8D%E5%92%8CJSONP%E4%BB%8B%E7%BB%8D/" title="Node.js学习(二十三.跨域介绍和JSONP介绍)">Node.js学习(二十三.跨域介绍和JSONP介绍)</a><time datetime="2021-03-21T13:40:58.000Z" title="发表于 2021-03-21 21:40:58">2021-03-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/20/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%BA%8C-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B-%E4%B8%8B/" title="Node.js学习(二十二.Node.js项目流程(下))"><img data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/CvAoe6kC5*f2.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Node.js学习(二十二.Node.js项目流程(下))"/></a><div class="content"><a class="title" href="/2021/03/20/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%BA%8C-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B-%E4%B8%8B/" title="Node.js学习(二十二.Node.js项目流程(下))">Node.js学习(二十二.Node.js项目流程(下))</a><time datetime="2021-03-20T14:33:29.000Z" title="发表于 2021-03-20 22:33:29">2021-03-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/15/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%B8%80-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B-%E4%B8%AD/" title="Node.js学习(二十一.Node.js项目流程(中))"><img data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/gSrAfCznw@^F.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Node.js学习(二十一.Node.js项目流程(中))"/></a><div class="content"><a class="title" href="/2021/03/15/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81%E4%B8%80-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B-%E4%B8%AD/" title="Node.js学习(二十一.Node.js项目流程(中))">Node.js学习(二十一.Node.js项目流程(中))</a><time datetime="2021-03-15T04:35:12.000Z" title="发表于 2021-03-15 12:35:12">2021-03-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/03/14/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B(%E4%B8%8A)/" title="Node.js学习(二十.Node.js项目流程(上))"><img data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210320/UMp@B^akHmf8.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Node.js学习(二十.Node.js项目流程(上))"/></a><div class="content"><a class="title" href="/2021/03/14/Node-js%E5%AD%A6%E4%B9%A0-%E4%BA%8C%E5%8D%81-Node-js%E9%A1%B9%E7%9B%AE%E6%B5%81%E7%A8%8B(%E4%B8%8A)/" title="Node.js学习(二十.Node.js项目流程(上))">Node.js学习(二十.Node.js项目流程(上))</a><time datetime="2021-03-14T14:36:58.000Z" title="发表于 2021-03-14 22:36:58">2021-03-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/02/27/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B9%9D-%E5%B0%81%E8%A3%85%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93%E5%92%8CCSRF/" title="Node.js学习(十九.封装操作数据库和CSRF)"><img data-lazy-src="https://gitee.com/he_chaoming/blog_tuchuang/raw/master/20210227/EcgLTE4WPOp^.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Node.js学习(十九.封装操作数据库和CSRF)"/></a><div class="content"><a class="title" href="/2021/02/27/Node-js%E5%AD%A6%E4%B9%A0-%E5%8D%81%E4%B9%9D-%E5%B0%81%E8%A3%85%E6%93%8D%E4%BD%9C%E6%95%B0%E6%8D%AE%E5%BA%93%E5%92%8CCSRF/" title="Node.js学习(十九.封装操作数据库和CSRF)">Node.js学习(十九.封装操作数据库和CSRF)</a><time datetime="2021-02-27T13:20:18.000Z" title="发表于 2021-02-27 21:20:18">2021-02-27</time></div></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 六根清静</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi,  welcome  to  my  <a  href="">blog</a>!</div><div class="icp"><a><img class="icp-icon" src="/img/icp.png" alt="ICP"/><span>豫ICP备2020025430号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">简</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="rightside.chat_btn"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"><div id="local-hits"></div><div id="local-stats"><div class="local-search-stats__hr" id="hr"><span>由</span> <a target="_blank" rel="noopener" href="https://github.com/wzpan/hexo-generator-search" style="color:#49B1F5;">hexo-generator-search</a>
 <span>提供支持</span></div></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module" defer></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script async="async">var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> {preloader.endLoading()})
setTimeout(function(){preloader.endLoading();}, 50000);</script><div class="js-pjax"><script>function loadValine () {
  function initValine () {
    let initData = {
      el: '#vcomment',
      appId: 'kW2ft895T235y7DxmyJmXX5X-MdYXbMMI',
      appKey: 'v0zBPCAdwiJ0xg4s4eSfusLD',
      placeholder: '建议使用QQ邮箱，评论头像采用QQ头像',
      avatar: 'monsterid',
      meta: 'nick,mail,link'.split(','),
      pageSize: '10',
      lang: 'zh-CN',
      recordIP: false,
      serverURLs: 'https://???????.api.lncldglobal.com',
      emojiCDN: '',
      emojiMaps: "",
      enableQQ: true,
      path: window.location.pathname,
      master: '1f76478c4ec918ffc6d50de6b68db531'.split(','),
      friends: '5c?????bfe6rfc72a????e268ad3819c,7c?????bfe65fc02a????e2????3919c'.split(','),
      tagMeta: '博主,小伙伴,访客'.split(',')
    }

    if (true) { 
      initData.requiredFields= ('nick,mail'.split(','))
    }
    
    if (false) {
      const otherData = false
      initData = Object.assign({}, initData, otherData)
    }
    
    const valine = new Valine(initData)
  }

  if (typeof Valine === 'function') initValine() 
  else $.getScript('https://cdn.jsdelivr.net/gh/HCLonely/Valine@latest/dist/Valine.min.js', initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.querySelector('#vcomment'),loadValine)
  else setTimeout(() => loadValine(), 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><script src='https://cdn.jsdelivr.net/npm/artitalk'></script><script> $(".category-list-count").prepend("<i class=\"fas fa-book\"></i>");</script><script src="/js/list.js"></script><script src="/js/gitcalendar.js"></script><script src="/js/calendar.js"></script><script src="/js/xkTool.js"></script><script src="/js/pjax.js"></script><script src="/magnet/js/vue.min.js"></script><script src="/magnet/js/catalogMagnet.js"></script><script src="/js/airvisualapi.js"></script><script src="/js/history.js"></script><script src="/js/historyroll.js"></script><script src="/js/change.js"></script><script type="text/javascript" src="https://www.airvisual.com/scripts/widget_v2.0.js"></script><script> setTimeout(function(){$('.monoline').eq(0).html($(".monoline strong").eq(0).text().replace('°','℃'));},5000);</script><script src="https://cdn.jsdelivr.net/gh/sviptzk/HexoStaticFile@latest/Hexo/js/mouse_snow.min.js"></script><script src="/js/myBg.js"></script><script src="/js/shuo.js"></script><script src="/js/artitalkkey.js"></script><script src="/news/js/keys.js"></script><script src="/news/js/news.js"></script><script src="https://cdn.jsdelivr.net/gh/sviptzk/StaticFile_HEXO@latest/butterfly/js/pool.min.js"><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/stars/stars.js"></script><script src="https://cdn1.lncld.net/static/js/3.5.0/av-min.js"></script><script src="/zan/zan.js"></script><div class="aplayer no-destroy" data-id="2916766519" data-server="netease" data-type="playlist" data-fixed="true" data-mini="true" data-listFolded="false" data-order="random" data-preload="none" data-autoplay="false" muted></div><script src="/swiper/swiper.min.js"></script><script src="/swiper/swiperindex.js"></script><script async src="//at.alicdn.com/t/font_2264842_3izu8i5eoc2.js"></script><canvas class="fireworks" mobile="false"></canvas><script src="/js/third-party/fireworks.js"></script><script src="/js/third-party/activate-power-mode.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script>(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/6fdec148.js","daovoice")
</script><script>var isChatBtn = true
daovoice('init', {
  app_id: '6fdec148',},{
  launcher: { 
     disableLauncherIcon: isChatBtn // 悬浮 ICON 是否显示
  },
});
daovoice('update');

if (isChatBtn) {
  var chatBtnFn = () => {
    var chatBtn = document.getElementById("chat_btn")
    chatBtn.addEventListener("click", function(){
      daovoice('show')
    });
  }
  chatBtnFn()
} else {
  if (true) {
    function chatBtnHide () {
      daovoice('update', {},{
        launcher: { 
        disableLauncherIcon: true // 悬浮 ICON 是否显示
        },
      });
    }
    function chatBtnShow () {
      daovoice('update', {},{
        launcher: { 
        disableLauncherIcon: false // 悬浮 ICON 是否显示
        },
      });
    }
  }
}</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/gh/metowolf/MetingJS@1.2/dist/Meting.min.js"></script></div><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"scale":1,"hHeadPos":0.5,"vHeadPos":0.618,"jsonPath":"/live2dw/assets/unitychan.model.json"},"display":{"superSample":2,"width":150,"height":300,"position":"right","hOffset":0,"vOffset":-20},"mobile":{"show":true,"scale":0.6},"react":{"opacityDefault":0.7,"opacityOnHover":0.8},"log":false});</script></body></html>